package com.stt.weather.design.controller;

import com.stt.weather.model.WeatherData;
import com.stt.weather.design.service.DesignWeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 天气数据控制器
 * 提供天气数据的REST API接口
 */
@RestController
@RequestMapping("/api/weather/v2")
public class DesignWeatherController {

    /**
     * 天气服务对象
     */
    @Autowired
    private DesignWeatherService designWeatherService;

    /**
     * 获取指定城市的天气数据
     *
     * @param cityCode 城市编号
     * @return 天气数据对象
     */
    @GetMapping("/{cityCode}")
    public WeatherData getWeatherData(@PathVariable("cityCode") String cityCode) {
        return designWeatherService.getWeatherData(cityCode);
    }

    @PostMapping("/notifications/{type}/enable")
    public void enableNotification(@PathVariable("type")  String type) {
        designWeatherService.enableNotification(type);
    }

    @PostMapping("/notifications/{type}/disable")
    public void disableNotification(@PathVariable("type")  String type) {
        designWeatherService.disableNotification(type);
    }
} 